package com.dxy.multids.controller;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.dxy.multids.pojo.OrderInfo;
import com.dxy.multids.service.OrderInfoService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/multids/order")
public class OrderInfoController {

    @Autowired
    private OrderInfoService orderInfoService;

    @PostMapping("/add")
    public OrderInfo add(Long userId, String orderName) {
        return orderInfoService.addOrder(userId, orderName);
    }

    @GetMapping("/getOrderByUserId")
    public IPage<OrderInfo> getOrderByUserId(Long userId, Long pageNum, Long pageSize) {
        return orderInfoService.getOrderByUserId(userId, pageNum, pageSize);
    }
}
